package com.bjpowernode.mvc.controller;


import cn.hutool.core.bean.BeanUtil;
import com.bjpowernode.db.domain.RechargeRecord;
import com.bjpowernode.mvc.model.response.Response;
import com.bjpowernode.mvc.model.vo.recharge.RechargeRecordVO;
import com.bjpowernode.mvc.service.Impl.RechargeServiceImpl;
import com.bjpowernode.mvc.service.inter.RechargeService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class RechargeController {
    //查询充值记录.

    @Resource
    private RechargeService rechargeService;
    @GetMapping(value = "/recharge/more")
    public Response queryRecharge(@RequestHeader("uid") Integer userId,Integer pageNo,Integer pageSize){
        pageNo=(pageNo == null || pageNo<1)?1:pageNo;
        pageSize=(pageSize == null || pageSize<1)?6:pageSize;

        //查询.
        List<RechargeRecord> rechargeList= rechargeService.queryRechargeByUid(userId,pageNo,pageSize);
        //转vo
        Response response=Response.ok(BeanUtil.copyToList(rechargeList, RechargeRecordVO.class));
        return response;

    }
}
